
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
Date Generated       : 3/29/2013 2:25:55 PM
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;



namespace DNNspot.LiveChat.DataModel
{
	/// <summary>
	/// Encapsulates the 'UserPortals' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(UserPortal))]	
	[XmlType("UserPortal")]
	public partial class UserPortal : esUserPortal
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new UserPortal();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Int32 userId, System.Int32 portalId)
		{
			var obj = new UserPortal();
			obj.UserId = userId;
			obj.PortalId = portalId;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Int32 userId, System.Int32 portalId, esSqlAccessType sqlAccessType)
		{
			var obj = new UserPortal();
			obj.UserId = userId;
			obj.PortalId = portalId;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("UserPortalCollection")]
	public partial class UserPortalCollection : esUserPortalCollection, IEnumerable<UserPortal>
	{
		public UserPortal FindByPrimaryKey(System.Int32 userId, System.Int32 portalId)
		{
			return this.SingleOrDefault(e => e.UserId == userId && e.PortalId == portalId);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(UserPortal))]
		public class UserPortalCollectionWCFPacket : esCollectionWCFPacket<UserPortalCollection>
		{
			public static implicit operator UserPortalCollection(UserPortalCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator UserPortalCollectionWCFPacket(UserPortalCollection collection)
			{
				return new UserPortalCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class UserPortalQuery : esUserPortalQuery
	{
		public UserPortalQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "UserPortalQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(UserPortalQuery query)
		{
			return UserPortalQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator UserPortalQuery(string query)
		{
			return (UserPortalQuery)UserPortalQuery.SerializeHelper.FromXml(query, typeof(UserPortalQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esUserPortal : esEntity
	{
		public esUserPortal()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Int32 userId, System.Int32 portalId)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(userId, portalId);
			else
				return LoadByPrimaryKeyStoredProcedure(userId, portalId);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Int32 userId, System.Int32 portalId)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(userId, portalId);
			else
				return LoadByPrimaryKeyStoredProcedure(userId, portalId);
		}

		private bool LoadByPrimaryKeyDynamic(System.Int32 userId, System.Int32 portalId)
		{
			UserPortalQuery query = new UserPortalQuery();
			query.Where(query.UserId == userId, query.PortalId == portalId);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Int32 userId, System.Int32 portalId)
		{
			esParameters parms = new esParameters();
			parms.Add("UserId", userId);			parms.Add("PortalId", portalId);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to UserPortals.UserId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? UserId
		{
			get
			{
				return base.GetSystemInt32(UserPortalMetadata.ColumnNames.UserId);
			}
			
			set
			{
				if(base.SetSystemInt32(UserPortalMetadata.ColumnNames.UserId, value))
				{
					this._UpToUserByUserId = null;
					this.OnPropertyChanged("UpToUserByUserId");
					OnPropertyChanged(UserPortalMetadata.PropertyNames.UserId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to UserPortals.PortalId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? PortalId
		{
			get
			{
				return base.GetSystemInt32(UserPortalMetadata.ColumnNames.PortalId);
			}
			
			set
			{
				if(base.SetSystemInt32(UserPortalMetadata.ColumnNames.PortalId, value))
				{
					OnPropertyChanged(UserPortalMetadata.PropertyNames.PortalId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to UserPortals.UserPortalId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? UserPortalId
		{
			get
			{
				return base.GetSystemInt32(UserPortalMetadata.ColumnNames.UserPortalId);
			}
			
			set
			{
				if(base.SetSystemInt32(UserPortalMetadata.ColumnNames.UserPortalId, value))
				{
					OnPropertyChanged(UserPortalMetadata.PropertyNames.UserPortalId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to UserPortals.CreatedDate
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? CreatedDate
		{
			get
			{
				return base.GetSystemDateTime(UserPortalMetadata.ColumnNames.CreatedDate);
			}
			
			set
			{
				if(base.SetSystemDateTime(UserPortalMetadata.ColumnNames.CreatedDate, value))
				{
					OnPropertyChanged(UserPortalMetadata.PropertyNames.CreatedDate);
				}
			}
		}		
		
		/// <summary>
		/// Maps to UserPortals.Authorised
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? Authorised
		{
			get
			{
				return base.GetSystemBoolean(UserPortalMetadata.ColumnNames.Authorised);
			}
			
			set
			{
				if(base.SetSystemBoolean(UserPortalMetadata.ColumnNames.Authorised, value))
				{
					OnPropertyChanged(UserPortalMetadata.PropertyNames.Authorised);
				}
			}
		}		
		
		/// <summary>
		/// Maps to UserPortals.IsDeleted
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsDeleted
		{
			get
			{
				return base.GetSystemBoolean(UserPortalMetadata.ColumnNames.IsDeleted);
			}
			
			set
			{
				if(base.SetSystemBoolean(UserPortalMetadata.ColumnNames.IsDeleted, value))
				{
					OnPropertyChanged(UserPortalMetadata.PropertyNames.IsDeleted);
				}
			}
		}		
		
		/// <summary>
		/// Maps to UserPortals.RefreshRoles
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? RefreshRoles
		{
			get
			{
				return base.GetSystemBoolean(UserPortalMetadata.ColumnNames.RefreshRoles);
			}
			
			set
			{
				if(base.SetSystemBoolean(UserPortalMetadata.ColumnNames.RefreshRoles, value))
				{
					OnPropertyChanged(UserPortalMetadata.PropertyNames.RefreshRoles);
				}
			}
		}		
		
		[CLSCompliant(false)]
		internal protected User _UpToUserByUserId;
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "UserId": this.str().UserId = (string)value; break;							
						case "PortalId": this.str().PortalId = (string)value; break;							
						case "UserPortalId": this.str().UserPortalId = (string)value; break;							
						case "CreatedDate": this.str().CreatedDate = (string)value; break;							
						case "Authorised": this.str().Authorised = (string)value; break;							
						case "IsDeleted": this.str().IsDeleted = (string)value; break;							
						case "RefreshRoles": this.str().RefreshRoles = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "UserId":
						
							if (value == null || value is System.Int32)
								this.UserId = (System.Int32?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.UserId);
							break;
						
						case "PortalId":
						
							if (value == null || value is System.Int32)
								this.PortalId = (System.Int32?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.PortalId);
							break;
						
						case "UserPortalId":
						
							if (value == null || value is System.Int32)
								this.UserPortalId = (System.Int32?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.UserPortalId);
							break;
						
						case "CreatedDate":
						
							if (value == null || value is System.DateTime)
								this.CreatedDate = (System.DateTime?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.CreatedDate);
							break;
						
						case "Authorised":
						
							if (value == null || value is System.Boolean)
								this.Authorised = (System.Boolean?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.Authorised);
							break;
						
						case "IsDeleted":
						
							if (value == null || value is System.Boolean)
								this.IsDeleted = (System.Boolean?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.IsDeleted);
							break;
						
						case "RefreshRoles":
						
							if (value == null || value is System.Boolean)
								this.RefreshRoles = (System.Boolean?)value;
								OnPropertyChanged(UserPortalMetadata.PropertyNames.RefreshRoles);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esUserPortal entity)
			{
				this.entity = entity;
			}
			
	
			public System.String UserId
			{
				get
				{
					System.Int32? data = entity.UserId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UserId = null;
					else entity.UserId = Convert.ToInt32(value);
				}
			}
				
			public System.String PortalId
			{
				get
				{
					System.Int32? data = entity.PortalId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.PortalId = null;
					else entity.PortalId = Convert.ToInt32(value);
				}
			}
				
			public System.String UserPortalId
			{
				get
				{
					System.Int32? data = entity.UserPortalId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UserPortalId = null;
					else entity.UserPortalId = Convert.ToInt32(value);
				}
			}
				
			public System.String CreatedDate
			{
				get
				{
					System.DateTime? data = entity.CreatedDate;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedDate = null;
					else entity.CreatedDate = Convert.ToDateTime(value);
				}
			}
				
			public System.String Authorised
			{
				get
				{
					System.Boolean? data = entity.Authorised;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Authorised = null;
					else entity.Authorised = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsDeleted
			{
				get
				{
					System.Boolean? data = entity.IsDeleted;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsDeleted = null;
					else entity.IsDeleted = Convert.ToBoolean(value);
				}
			}
				
			public System.String RefreshRoles
			{
				get
				{
					System.Boolean? data = entity.RefreshRoles;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.RefreshRoles = null;
					else entity.RefreshRoles = Convert.ToBoolean(value);
				}
			}
			

			private esUserPortal entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return UserPortalMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public UserPortalQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new UserPortalQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(UserPortalQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(UserPortalQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private UserPortalQuery query;		
	}



	[Serializable]
	abstract public partial class esUserPortalCollection : esEntityCollection<UserPortal>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return UserPortalMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "UserPortalCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public UserPortalQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new UserPortalQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(UserPortalQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new UserPortalQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(UserPortalQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((UserPortalQuery)query);
		}

		#endregion
		
		private UserPortalQuery query;
	}



	[Serializable]
	abstract public partial class esUserPortalQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return UserPortalMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "UserId": return this.UserId;
				case "PortalId": return this.PortalId;
				case "UserPortalId": return this.UserPortalId;
				case "CreatedDate": return this.CreatedDate;
				case "Authorised": return this.Authorised;
				case "IsDeleted": return this.IsDeleted;
				case "RefreshRoles": return this.RefreshRoles;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem UserId
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.UserId, esSystemType.Int32); }
		} 
		
		public esQueryItem PortalId
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.PortalId, esSystemType.Int32); }
		} 
		
		public esQueryItem UserPortalId
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.UserPortalId, esSystemType.Int32); }
		} 
		
		public esQueryItem CreatedDate
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.CreatedDate, esSystemType.DateTime); }
		} 
		
		public esQueryItem Authorised
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.Authorised, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsDeleted
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.IsDeleted, esSystemType.Boolean); }
		} 
		
		public esQueryItem RefreshRoles
		{
			get { return new esQueryItem(this, UserPortalMetadata.ColumnNames.RefreshRoles, esSystemType.Boolean); }
		} 
		
		#endregion
		
	}


	
	public partial class UserPortal : esUserPortal
	{

				
		#region UpToUserByUserId - Many To One
		/// <summary>
		/// Many to One
		/// Foreign Key Name - FK_UserPortals_Users
		/// </summary>

		[XmlIgnore]
					
		public User UpToUserByUserId
		{
			get
			{
				if (this.es.IsLazyLoadDisabled) return null;
				
				if(this._UpToUserByUserId == null && UserId != null)
				{
					this._UpToUserByUserId = new User();
					this._UpToUserByUserId.es.Connection.Name = this.es.Connection.Name;
					this.SetPreSave("UpToUserByUserId", this._UpToUserByUserId);
					this._UpToUserByUserId.Query.Where(this._UpToUserByUserId.Query.UserID == this.UserId);
					this._UpToUserByUserId.Query.Load();
				}	
				return this._UpToUserByUserId;
			}
			
			set
			{
				this.RemovePreSave("UpToUserByUserId");
				

				if(value == null)
				{
					this.UserId = null;
					this._UpToUserByUserId = null;
				}
				else
				{
					this.UserId = value.UserID;
					this._UpToUserByUserId = value;
					this.SetPreSave("UpToUserByUserId", this._UpToUserByUserId);
				}
				
			}
		}
		#endregion
		

		
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PreSave.
		/// </summary>
		protected override void ApplyPreSaveKeys()
		{
			if(!this.es.IsDeleted && this._UpToUserByUserId != null)
			{
				this.UserId = this._UpToUserByUserId.UserID;
			}
		}
		
	}
	



	[Serializable]
	public partial class UserPortalMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected UserPortalMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.UserId, 0, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = UserPortalMetadata.PropertyNames.UserId;
			c.IsInPrimaryKey = true;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.PortalId, 1, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = UserPortalMetadata.PropertyNames.PortalId;
			c.IsInPrimaryKey = true;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.UserPortalId, 2, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = UserPortalMetadata.PropertyNames.UserPortalId;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.CreatedDate, 3, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = UserPortalMetadata.PropertyNames.CreatedDate;
			c.HasDefault = true;
			c.Default = @"(getdate())";
			m_columns.Add(c);
				
			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.Authorised, 4, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = UserPortalMetadata.PropertyNames.Authorised;
			c.HasDefault = true;
			c.Default = @"((1))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.IsDeleted, 5, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = UserPortalMetadata.PropertyNames.IsDeleted;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(UserPortalMetadata.ColumnNames.RefreshRoles, 6, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = UserPortalMetadata.PropertyNames.RefreshRoles;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public UserPortalMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string UserId = "UserId";
			 public const string PortalId = "PortalId";
			 public const string UserPortalId = "UserPortalId";
			 public const string CreatedDate = "CreatedDate";
			 public const string Authorised = "Authorised";
			 public const string IsDeleted = "IsDeleted";
			 public const string RefreshRoles = "RefreshRoles";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string UserId = "UserId";
			 public const string PortalId = "PortalId";
			 public const string UserPortalId = "UserPortalId";
			 public const string CreatedDate = "CreatedDate";
			 public const string Authorised = "Authorised";
			 public const string IsDeleted = "IsDeleted";
			 public const string RefreshRoles = "RefreshRoles";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(UserPortalMetadata))
			{
				if(UserPortalMetadata.mapDelegates == null)
				{
					UserPortalMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (UserPortalMetadata.meta == null)
				{
					UserPortalMetadata.meta = new UserPortalMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("UserId", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("PortalId", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("UserPortalId", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("CreatedDate", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("Authorised", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsDeleted", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("RefreshRoles", new esTypeMap("bit", "System.Boolean"));			
				
				
				
				meta.Source = "UserPortals";
				meta.Destination = "UserPortals";
				
				meta.spInsert = "proc_UserPortalsInsert";				
				meta.spUpdate = "proc_UserPortalsUpdate";		
				meta.spDelete = "proc_UserPortalsDelete";
				meta.spLoadAll = "proc_UserPortalsLoadAll";
				meta.spLoadByPrimaryKey = "proc_UserPortalsLoadByPrimaryKey";
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private UserPortalMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
